package com.thunbu.thunbu_meeting_system.viewMdel

import androidx.lifecycle.MutableLiveData
import com.thunbu.lib_common.base.CoroutineViewModel
import com.thunbu.thunbu_meeting_system.await
import com.thunbu.thunbu_meeting_system.bean.AssetPageModel
import com.thunbu.thunbu_meeting_system.launch
import com.thunbu.thunbu_meeting_system.service.ApiService
import com.thunbu.thunbu_meeting_system.service.MainNet
import com.thunbu.thunbu_meeting_system.ternary
import com.thunbu.thunbu_meeting_system.toRequestBody

class MyAssetsVM : CoroutineViewModel<Unit>() {
    val assetPage = MutableLiveData<AssetPageModel>()

    override fun initModel() {

    }

    fun queryAssetList(assetTypeName: String?, assetName: String?, mPage: Int, originalPage: Int) {
        launch({
            val map = mutableMapOf<String, Any?>("current" to mPage,
                "pageSize" to originalPage)
            if(assetTypeName != "全部"){
//                map["zichanflbm"] = assetTypeCode
                map["zichanflmc"] = assetTypeName
            }
            if(!assetName.isNullOrEmpty()){
                map["zichanmc"] = assetName
            }
            val result = MainNet.server(ApiService::class.java).queryAssetList(map.toRequestBody()).await(true,true)
            assetPage.value = result.data
        })
    }
}